package net.opentsdb.stats;

import com.stumbleupon.async.Deferred;
import net.opentsdb.core.TSDB;
import net.opentsdb.tools.BuildData;
import net.opentsdb.tsd.HttpQuery;
import net.opentsdb.tsd.HttpRpc;
import net.opentsdb.tsd.TelnetRpc;
import net.opentsdb.utils.JSON;
import org.jboss.netty.channel.Channel;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author hujf
 * @Date 2021/12/31 14:38
 * @Description TODO
 */
public class Version implements TelnetRpc, HttpRpc {

    /**
     * http 请求
     * @param tsdb The TSDB to use.
     * @param query The HTTP query to execute.
     * @throws IOException
     */

    @Override
    public void execute(TSDB tsdb, HttpQuery query) {
        Map version = new HashMap<>(2);
        version.put("version", BuildData.version);
        version.put("Owner",BuildData.host);
        query.sendReply(JSON.serializeToBytes(version));
    }


    /**
     * telnet 请求
     * @param tsdb The TSDB to use.
     * @param chan The channel on which the RPC was received.
     * @param command The command received, split.
     * @return
     */
    @Override
    public Deferred<Object> execute(TSDB tsdb, Channel chan, String[] command) {
        return null;
    }
}
